<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:totoland="http://java.sun.com/jsf/composite/components">
    <h:head>               
    </h:head>
    <h:body>
        <ui:composition template="../../template/etcTemplateGreen.xhtml">
            <ui:define name="content">
                <h:form id="form1" prependId="false">
                    <p:panel header="หน้าออกรายงาน">
                        <p:panelGrid columns="4" style="width: 100%;" styleClass="frmSelect" id="searchCriteria">
                            <f:facet name="header">เงื่อนไขการแสดงรายงาน</f:facet>     
                            <p:outputLabel value="#{msg.label_fiscal_year} :" />
                            <p:selectOneMenu style="width: 220px;" value="#{allReportController.reportCriteria.year}">
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" /> 
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlFiscalYear()}"></f:selectItems>  
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกเดือน : " />
                            <p:selectOneMenu style="width: 220px;" value="#{allReportController.reportCriteria.month}">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlMonth()}"></f:selectItems>
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกประเภทรายงานผลการปฏิบัติการ : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlReportOperating()}"></f:selectItems> 
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกแบบรายงาน : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlReportForm()}"></f:selectItems>  
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกยุทธศาสตร์ที่ : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001strategicId" value="#{allReportController.reportCriteria.strategic}" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" 
                                               value="#{allReportController.dropdownFactory.ddlStrategic()}">
                                </f:selectItems>
                                <p:ajax update="subStrategicId"/>  
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกกลยุทธ์ : " id="REPORT_001subStrategicId" rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" id="subStrategicId" value="#{allReportController.reportCriteria.subStrategic}" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlSubStrategic(allReportController.reportCriteria.strategic)}"></f:selectItems>
                                <p:ajax update="REPORT_001planId"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกแผนงาน : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001planId" value="#{allReportController.reportCriteria.plan}" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlPlan(allReportController.reportCriteria.subStrategic)}"></f:selectItems>  
                                <p:ajax update="REPORT_001projectId"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกโครงการ : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001projectId"  value="#{allReportController.reportCriteria.project}" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlProject(allReportController.reportCriteria.plan)}"></f:selectItems> 
                                <p:ajax update="REPORT_001Activity"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกกิจกรรม : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001Activity" value="#{allReportController.reportCriteria.activity}" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlActivity(allReportController.reportCriteria.project)}"></f:selectItems> 
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกสถานะ : "/>
                            <p:selectOneMenu style="width: 220px" value="#{allReportController.reportCriteria.status}">  
                                <f:selectItem itemLabel="เลือก" itemValue="" />  
                                <f:selectItem itemLabel="รอพิจารณา" itemValue="0,101,102,103" />  
                                <f:selectItem itemLabel="ไม่อนุมัติ" itemValue="-1" />  
                                <f:selectItem itemLabel="อนุมัติ" itemValue="200" />
                            </p:selectOneMenu>

                            <h:outputLabel value="Manage Assign Tracing  สนง.กกต. ส่วนกลาง" rendered="#{param.user==null}"/>
                            <p:selectOneMenu  id="ectDll2" style="width: 220px" rendered="#{param.user==null}" value="#{allReportController.reportCriteria.reportCode}">  
                                <f:selectItem itemLabel="-เลือก-" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{allReportController.dropdownFactory.ddlDepEct()}"/>  
                            </p:selectOneMenu>
                            <f:facet name="footer">
                                <div align="center">
                                    <p:commandButton id="btnShowRpt" action="#{allReportController.search()}" update="rptPreSendList2" value="แสดงรายงาน"/>
                                    <p:commandButton id="btnResetwRpt" action="#{allReportController.resetForm()}" update="searchCriteria,rptPreSendList2" value="เริ่มใหม่"/>
                                </div>
                            </f:facet>
                        </p:panelGrid><br/>       
                        <p:dataTable id="rptPreSendList2" var="item" value="#{allReportController.lazyModel}"
                                     paginator="true" rows="10" lazy="true" emptyMessage="#{msg.no_data_found}"
                                     currentPageReportTemplate="#{msg.current_pagereport_template}"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="10,15,20">

                            <p:column sortBy="documentNo">
                                <f:facet name="header">
                                    <h:outputText value="เลขที่เอกสาร" />
                                </f:facet>
                                <h:outputText value="#{item.documentNo}" />
                            </p:column>

                            <p:column sortBy="user_Group_Name">
                                <f:facet name="header">
                                    <h:outputText value="หน่วยงาน" />
                                </f:facet>
                                <h:outputText value="#{item.userGroupName}" />
                            </p:column>
                            
                            <p:column sortBy="report_Desc" style="width:350px">
                                <f:facet name="header">
                                    <h:outputText value="ชื่อรายงาน" />
                                </f:facet>
                                <h:outputText value="#{item.reportDesc}" />
                            </p:column>

                            <p:column sortBy="flow_Status_Name">
                                <f:facet name="header">
                                    <h:outputText value="สถานะ" />
                                </f:facet>
                                <h:outputText value="#{item.flowStatusName}"/>
                            </p:column>
                            <p:column sortBy="created_Date">
                                <f:facet name="header">
                                    <h:outputText value="ประจำเดือน/ปี" />
                                </f:facet>
                                <h:outputText value="#{allReportController.dropdownFactory.getMonthName(item.reportMonth)} #{item.reportYear}"/>
                            </p:column>
                            <p:column sortBy="created_User_Full_Name">
                                <f:facet name="header">
                                    <h:outputText value="ชื่อผู้สร้าง" />
                                </f:facet>
                                <h:outputText value="#{item.createdUserFullName}" />
                            </p:column>
                            <p:column width="100">
                                <f:facet name="header">
                                    <h:outputText value="ส่งออก Excel" />
                                </f:facet>
                                <p:commandButton id="downloadLink" value="ดาวน์โหลด" ajax="false" action="#{allReportController.fileXLSDownload(item)}"   
                                                 icon="ui-icon-arrowthichk-s">
                                </p:commandButton>
                            </p:column>
                            <f:facet name="footer">

                            </f:facet>
                        </p:dataTable>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>